// server/utils/compressWorker.js
import { parentPort } from "worker_threads";
// import LZString from "../../server/node_modules/lz-string/libs/lz-string.js";
let LZString;
if (process.env.NODE_ENV != "development") {
  LZString = await import(
    "../../server/node_modules/lz-string/libs/lz-string.js"
  );
} else {
  LZString = await import("lz-string");
}
// console.log("LZString--1111", LZString);
// 监听来自主线程的消息
parentPort.once("message", (message) => {
  const compressedData = LZString.default.compressToUTF16(message);
  parentPort.postMessage(compressedData); // 发送消息回主线程
});
